package com.example

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.api.scala._
object MapDemo1 {

  case class Student(id:Int,name:String)

  def main(args: Array[String]): Unit = {
    val environment = ExecutionEnvironment.getExecutionEnvironment
    val df: DataSet[(Int, String)] = environment.fromCollection(List((1, "zhang"), (2, "lisi")))

    df.print()

    val map: DataSet[Student] = df.map(line => {
      Student(line._1.toInt, line._2.toString)
    })

    map.print()

    val mapPart = df.mapPartition(iter => {
      val students: Iterator[Student] = iter.map(line => {
        Student(line._1.toInt, line._2.toString)
      })
      students
    })

    mapPart.print()







  }
}
